package com.wx.spider.common.model;

import java.util.List;

/**
 * @author:feng
 * @create:2021-04-22 11:33
 */
public class Pager<T>{

    private long total;// 总记录数

    private List<T> datas;// 数据

    private int pageNum=1;// 第N页

    private int numPerPage=20;// 一页显示多少条

    //private long pageCount;//总ti

    public Pager() {
        super();
    }

    /**
     * 计算总页数
     * @return
     */
    public long getPageCount() {
        return total%numPerPage == 0 ? total/numPerPage : total/numPerPage+1;
    }

    public Pager(String pagenum,String pagesize) {
        if(pagenum != null){
            pageNum = Integer.parseInt(pagenum);
        }
        if(pagesize != null){
            numPerPage = Integer.parseInt(pagesize);
        }
    }

    public long getTotal(){
        return total;
    }

    public void setTotal(long total){
        this.total=total;
    }

    public List<T> getDatas(){
        return datas;
    }

    public void setDatas(List<T> datas){
        this.datas=datas;
    }

    public int getPageNum(){
        return pageNum;
    }

    public void setPageNum(int pageNum){
        this.pageNum=pageNum;
    }

    public int getNumPerPage(){
        return numPerPage;
    }

    public void setNumPerPage(int numPerPage){
        this.numPerPage=numPerPage;
    }

}